package com.ztmg.water.controller.bills;

import com.ztmg.common.util.resultUtils.JsonResult;;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;


import com.ztmg.water.vo.bills.OutPutBillsVO;
import com.ztmg.water.dto.bills.OutPutBillsDTO;
import com.ztmg.water.dto.bills.OutPutBillsPageDTO;
import com.ztmg.water.service.bills.OutPutBillsService;

import java.util.HashMap;
import java.util.Map;


/**
 * 
 * OutPutBillsControllerController
 * 
 **/

@Api(description = "出库单接口")
@RestController
@RequestMapping(value = "/outPutBills")
public class OutPutBillsController{

	@Resource
	private OutPutBillsService outPutBillsService;

    @PostMapping("create")
    @ApiOperation("新增")
    public JsonResult create(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.create(dto);
    }

    @GetMapping("getRecycleBucketNum/{id}")
    @ApiOperation("获取当前出货单回收桶数")
    public JsonResult getRecycleBucketNum(@PathVariable Integer id){
        return outPutBillsService.getRecycleBucketSum(id);

    }

    @PostMapping("updateOutPutBillsAuditStatus")
    @ApiOperation("配送审核")
    public JsonResult updateOutPutBillsAuditStatus(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.updateOutPutBillsAuditStatus(dto);
    }
    @PostMapping("update")
    @ApiOperation("修改")
    public JsonResult update(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.update(dto);
    }
    @PostMapping("validateCollectData")
    @ApiOperation("校验收集数据")
    public JsonResult<Map<String,Object>> validateCollectData(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.handleCollectDate(dto);
    }

    @GetMapping("detail/{id}")
    @ApiOperation("详情")
    public JsonResult<OutPutBillsVO> detail(@PathVariable Integer id){
        return outPutBillsService.selectById(id);
    }

    @PostMapping("select")
    @ApiOperation("条件查询")
    public JsonResult<OutPutBillsVO> detail(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.select(dto);
    }

    @PostMapping("queryPage")
    @ApiOperation("分页查询")
    public JsonResult<PageInfo<OutPutBillsVO>> queryPage(@RequestBody OutPutBillsPageDTO dto){
        return outPutBillsService.selectPage(dto);
    }

    @PostMapping("delete")
    @ApiOperation("条件删除")
    public JsonResult delete(@RequestBody OutPutBillsDTO dto){
        return outPutBillsService.delete(dto);
    }

    @GetMapping("deleteById/{id}")
    @ApiOperation("删除")
    public JsonResult deleteById(@PathVariable Integer id){
        return outPutBillsService.deleteById(id);
    }

    @PostMapping("deleteBillsOrderById")
    @ApiOperation("移除出货单ID")
    public JsonResult deleteOrderFromOutPutBillsById(@RequestBody OutPutBillsDTO dto){
        Map<String,String> params = new HashMap<>(2);
        params.put("orderId",dto.getOrderIds());
        params.put("id",dto.getId().toString());
        return outPutBillsService.deleteOrderFromOutPutBillsById(params);
    }

}